home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Developer Essentials / MPW Interfaces & Libraries / PInterfaces / MIDI.p < prev    next >
Encoding:
Text File  |  1992-01-29  |  9.4 KB  |  266 lines  |  [TEXT/MPS ]

  1.  
  2. {
  3. Created: Tuesday, November 26, 1991 at 3:28 PM
  4.  MIDI.p
  5.  Pascal Interface to the Macintosh Libraries
  6.  
  7.   Copyright Apple Computer, Inc. 1988-1991
  8.   All rights reserved
  9. }
  10.  
  11.  
  12. {$IFC UNDEFINED UsingIncludes}
  13. {$SETC UsingIncludes := 0}
  14. {$ENDC}
  15.  
  16. {$IFC NOT UsingIncludes}
  17.  UNIT MIDI;
  18.  INTERFACE
  19. {$ENDC}
  20.  
  21. {$IFC UNDEFINED UsingMIDI}
  22. {$SETC UsingMIDI := 1}
  23.  
  24. {$I+}
  25. {$SETC MIDIIncludes := UsingIncludes}
  26. {$SETC UsingIncludes := 1}
  27. {$IFC UNDEFINED UsingTypes}
  28. {$I $$Shell(PInterfaces)Types.p}
  29. {$ENDC}
  30. {$SETC UsingIncludes := MIDIIncludes}
  31.  
  32. CONST
  33. midiToolNum = 4;                    {tool number of MIDI Manager for SndDispVersion call}
  34. midiMaxNameLen = 31;                {maximum number of characters in port and client names}
  35.  
  36. { Time formats }
  37. midiFormatMSec = 0;                    {milliseconds}
  38. midiFormatBeats = 1;                {beats}
  39. midiFormat24fpsBit = 2;                {24 frames/sec.}
  40. midiFormat25fpsBit = 3;                {25 frames/sec.}
  41. midiFormat30fpsDBit = 4;            {30 frames/sec. drop-frame}
  42. midiFormat30fpsBit = 5;                {30 frames/sec.}
  43. midiFormat24fpsQF = 6;                {24 frames/sec. longInt format }
  44. midiFormat25fpsQF = 7;                {25 frames/sec. longInt format }
  45. midiFormat30fpsDQF = 8;                {30 frames/sec. drop-frame longInt format }
  46. midiFormat30fpsQF = 9;                {30 frames/sec. longInt format }
  47. midiInternalSync = 0;                {internal sync}
  48. midiExternalSync = 1;                {external sync}
  49.  
  50. { Port types}
  51. midiPortTypeTime = 0;                {time port}
  52. midiPortTypeInput = 1;                {input port}
  53. midiPortTypeOutput = 2;                {output port}
  54. midiPortTypeTimeInv = 3;            {invisible time port}
  55.  
  56. { OffsetTimes  }
  57. midiGetEverything = $7FFFFFFF;        {get all packets, regardless of time stamps}
  58. midiGetNothing = $80000000;            {get no packets, regardless of time stamps}
  59. midiGetCurrent = $00000000;            {get current packets only}
  60.  
  61. {    MIDI data and messages are passed in MIDIPacket records (see below).
  62.     The first byte of every MIDIPacket contains a set of flags
  63.    
  64.     bits 0-1    00 = new MIDIPacket, not continued
  65.                      01 = begining of continued MIDIPacket
  66.                      10 = end of continued MIDIPacket
  67.                     11 = continuation
  68.     bits 2-3     reserved
  69.   
  70.     bits 4-6      000 = packet contains MIDI data
  71.    
  72.                      001 = packet contains MIDI Manager message
  73.    
  74.     bit 7              0 = MIDIPacket has valid stamp
  75.                         1 = stamp with current clock }
  76. midiContMask = $03;
  77. midiNoCont = $00;
  78. midiStartCont = $01;
  79. midiMidCont = $03;
  80. midiEndCont = $02;
  81. midiTypeMask = $70;
  82. midiMsgType = $00;
  83. midiMgrType = $10;
  84. midiTimeStampMask = $80;
  85. midiTimeStampCurrent = $80;
  86. midiTimeStampValid = $00;
  87.  
  88. {    MIDI Manager MIDIPacket command words (the first word in the data field
  89.     for midiMgrType messages) }
  90. midiOverflowErr = $0001;
  91. midiSCCErr = $0002;
  92. midiPacketErr = $0003;
  93. midiMaxErr = $00FF;                    {all command words less than this value  are error indicators}
  94.  
  95. { Valid results to be returned by readHooks }
  96. midiKeepPacket = 0;
  97. midiMorePacket = 1;
  98. midiNoMorePacket = 2;
  99.  
  100. { Errors: }
  101. midiNoClientErr = -250;                {no client with that ID found}
  102. midiNoPortErr = -251;                {no port with that ID found}
  103. midiTooManyPortsErr = -252;            {too many ports already installed in the system}
  104. midiTooManyConsErr = -253;            {too many connections made}
  105. midiVConnectErr = -254;                {pending virtual connection created}
  106. midiVConnectMade = -255;            {pending virtual connection resolved}
  107. midiVConnectRmvd = -256;            {pending virtual connection removed}
  108. midiNoConErr = -257;                {no connection exists between specified ports}
  109. midiWriteErr = -258;                {MIDIWritePacket couldn't write to all connected ports}
  110. midiNameLenErr = -259;                {name supplied is longer than 31 characters}
  111. midiDupIDErr = -260;                {duplicate client ID}
  112. midiInvalidCmdErr = -261;            {command not supported for port type}
  113.  
  114. {     Driver calls: }
  115. midiOpenDriver = 1;
  116. midiCloseDriver = 2;
  117.  
  118. TYPE
  119. MIDIPacketPtr = ^MIDIPacket;
  120. MIDIPacket = PACKED RECORD
  121.  flags: Byte;
  122.  len: Byte;
  123.  tStamp: LONGINT;
  124.  data: PACKED ARRAY [0..248] OF Byte;
  125.  END;
  126.  
  127. MIDIClkInfo = RECORD
  128.  sync: INTEGER;                        {synchronization external/internal}
  129.  curTime: LONGINT;                    {current value of port's clock}
  130.  format: INTEGER;                    {time code format}
  131.  END;
  132.  
  133. MIDIIDRec = RECORD
  134.  clientID: OSType;
  135.  portID: OSType;
  136.  END;
  137.  
  138. MIDIPortInfoPtr = ^MIDIPortInfo;
  139. MIDIPortInfoHdl = ^MIDIPortInfoPtr;
  140. MIDIPortInfo = RECORD
  141.  portType: INTEGER;                    {type of port}
  142.  timeBase: MIDIIDRec;                {MIDIIDRec for time base}
  143.  numConnects: INTEGER;                {number of connections}
  144.  cList: ARRAY [1..1] OF MIDIIDRec;    {-r or $R- permits access to [1..numConnects] of MIDIIDRec}
  145.  END;
  146.  
  147. MIDIPortParamsPtr = ^MIDIPortParams;
  148. MIDIPortParams = RECORD
  149.  portID: OSType;                    {ID of port, unique within client}
  150.  portType: INTEGER;                    {Type of port - input, output, time, etc.}
  151.  timeBase: INTEGER;                    {refnum of time base, 0 if none}
  152.  offsetTime: LONGINT;                {offset for current time stamps}
  153.  readHook: Ptr;                        {routine to call when input data is valid}
  154.  refCon: LONGINT;                    {refcon for port (for client use)}
  155.  initClock: MIDIClkInfo;            {initial settings for a time base}
  156.  name: Str255;                        {name of the port, This is a real live string, not a ptr.}
  157.  END;
  158.  
  159. MIDIIDListPtr = ^MIDIIDList;
  160. MIDIIDListHdl = ^MIDIIDListPtr;
  161. MIDIIDList = RECORD
  162.  numIDs: INTEGER;
  163.  list: ARRAY [1..1] OF OSType;        { -r or $R- permits access to [1..numIDs] of OSType }
  164.  END;
  165.  
  166.  
  167. {
  168.      Prototype Declarations for readHook and timeProc
  169.     
  170.      FUNCTION myReadHook(myPacket: MIDIPacketPtr; myRefCon: LONGINT) : INTEGER;
  171.      PROCEDURE myTimeProc(curTime: LONGINT; myRefCon: LONGINT);
  172. }
  173.  
  174. FUNCTION SndDispVersion(toolnum: INTEGER): LONGINT;
  175. FUNCTION MIDISignIn(clientID: OSType;refCon: LONGINT;icon: Handle;name: Str255): OSErr;
  176.  INLINE $203C,$0004,midiToolNum,$A800;
  177. PROCEDURE MIDISignOut(clientID: OSType);
  178.  INLINE $203C,$0008,midiToolNum,$A800;
  179. FUNCTION MIDIGetClients: MIDIIDListHdl;
  180.  INLINE $203C,$000C,midiToolNum,$A800;
  181. PROCEDURE MIDIGetClientName(clientID: OSType;VAR name: Str255);
  182.  INLINE $203C,$0010,midiToolNum,$A800;
  183. PROCEDURE MIDISetClientName(clientID: OSType;name: Str255);
  184.  INLINE $203C,$0014,midiToolNum,$A800;
  185. FUNCTION MIDIGetPorts(clientID: OSType): MIDIIDListHdl;
  186.  INLINE $203C,$0018,midiToolNum,$A800;
  187. FUNCTION MIDIAddPort(clientID: OSType;BufSize: INTEGER;VAR refnum: INTEGER;
  188.  init: MIDIPortParamsPtr): OSErr;
  189.  INLINE $203C,$001C,midiToolNum,$A800;
  190. FUNCTION MIDIGetPortInfo(clientID: OSType;portID: OSType): MIDIPortInfoHdl;
  191.  INLINE $203C,$0020,midiToolNum,$A800;
  192. FUNCTION MIDIConnectData(srcClID: OSType;srcPortID: OSType;dstClID: OSType;
  193.  dstPortID: OSType): OSErr;
  194.  INLINE $203C,$0024,midiToolNum,$A800;
  195. FUNCTION MIDIUnConnectData(srcClID: OSType;srcPortID: OSType;dstClID: OSType;
  196.  dstPortID: OSType): OSErr;
  197.  INLINE $203C,$0028,midiToolNum,$A800;
  198. FUNCTION MIDIConnectTime(srcClID: OSType;srcPortID: OSType;dstClID: OSType;
  199.  dstPortID: OSType): OSErr;
  200.  INLINE $203C,$002C,midiToolNum,$A800;
  201. FUNCTION MIDIUnConnectTime(srcClID: OSType;srcPortID: OSType;dstClID: OSType;
  202.  dstPortID: OSType): OSErr;
  203.  INLINE $203C,$0030,midiToolNum,$A800;
  204. PROCEDURE MIDIFlush(refnum: INTEGER);
  205.  INLINE $203C,$0034,midiToolNum,$A800;
  206. FUNCTION MIDIGetReadHook(refnum: INTEGER): ProcPtr;
  207.  INLINE $203C,$0038,midiToolNum,$A800;
  208. PROCEDURE MIDISetReadHook(refnum: INTEGER;hook: ProcPtr);
  209.  INLINE $203C,$003C,midiToolNum,$A800;
  210. PROCEDURE MIDIGetPortName(clientID: OSType;portID: OSType;VAR name: Str255);
  211.  INLINE $203C,$0040,midiToolNum,$A800;
  212. PROCEDURE MIDISetPortName(clientID: OSType;portID: OSType;name: Str255);
  213.  INLINE $203C,$0044,midiToolNum,$A800;
  214. PROCEDURE MIDIWakeUp(refnum: INTEGER;time: LONGINT;period: LONGINT;timeProc: ProcPtr);
  215.  INLINE $203C,$0048,midiToolNum,$A800;
  216. PROCEDURE MIDIRemovePort(refnum: INTEGER);
  217.  INLINE $203C,$004C,midiToolNum,$A800;
  218. FUNCTION MIDIGetSync(refnum: INTEGER): INTEGER;
  219.  INLINE $203C,$0050,midiToolNum,$A800;
  220. PROCEDURE MIDISetSync(refnum: INTEGER;sync: INTEGER);
  221.  INLINE $203C,$0054,midiToolNum,$A800;
  222. FUNCTION MIDIGetCurTime(refnum: INTEGER): LONGINT;
  223.  INLINE $203C,$0058,midiToolNum,$A800;
  224. PROCEDURE MIDISetCurTime(refnum: INTEGER;time: LONGINT);
  225.  INLINE $203C,$005C,midiToolNum,$A800;
  226. PROCEDURE MIDIStartTime(refnum: INTEGER);
  227.  INLINE $203C,$0060,midiToolNum,$A800;
  228. PROCEDURE MIDIStopTime(refnum: INTEGER);
  229.  INLINE $203C,$0064,midiToolNum,$A800;
  230. PROCEDURE MIDIPoll(refnum: INTEGER;offsetTime: LONGINT);
  231.  INLINE $203C,$0068,midiToolNum,$A800;
  232. FUNCTION MIDIWritePacket(refnum: INTEGER;packet: MIDIPacketPtr): OSErr;
  233.  INLINE $203C,$006C,midiToolNum,$A800;
  234. FUNCTION MIDIWorldChanged(clientID: OSType): BOOLEAN;
  235.  INLINE $203C,$0070,midiToolNum,$A800;
  236. FUNCTION MIDIGetOffsetTime(refnum: INTEGER): LONGINT;
  237.  INLINE $203C,$0074,midiToolNum,$A800;
  238. PROCEDURE MIDISetOffsetTime(refnum: INTEGER;offsetTime: LONGINT);
  239.  INLINE $203C,$0078,midiToolNum,$A800;
  240. FUNCTION MIDIConvertTime(srcFormat: INTEGER;dstFormat: INTEGER;time: LONGINT): LONGINT;
  241.  INLINE $203C,$007C,midiToolNum,$A800;
  242. FUNCTION MIDIGetRefCon(refnum: INTEGER): LONGINT;
  243.  INLINE $203C,$0080,midiToolNum,$A800;
  244. PROCEDURE MIDISetRefCon(refnum: INTEGER;refCon: LONGINT);
  245.  INLINE $203C,$0084,midiToolNum,$A800;
  246. FUNCTION MIDIGetClRefCon(clientID: OSType): LONGINT;
  247.  INLINE $203C,$0088,midiToolNum,$A800;
  248. PROCEDURE MIDISetClRefCon(clientID: OSType;refCon: LONGINT);
  249.  INLINE $203C,$008C,midiToolNum,$A800;
  250. FUNCTION MIDIGetTCFormat(refnum: INTEGER): INTEGER;
  251.  INLINE $203C,$0090,midiToolNum,$A800;
  252. PROCEDURE MIDISetTCFormat(refnum: INTEGER;format: INTEGER);
  253.  INLINE $203C,$0094,midiToolNum,$A800;
  254. PROCEDURE MIDISetRunRate(refnum: INTEGER;rate: INTEGER;time: LONGINT);
  255.  INLINE $203C,$0098,midiToolNum,$A800;
  256. FUNCTION MIDIGetClientIcon(clientID: OSType): Handle;
  257.  INLINE $203C,$009C,midiToolNum,$A800;
  258.  
  259.  
  260. {$ENDC} { UsingMIDI }
  261.  
  262. {$IFC NOT UsingIncludes}
  263.  END.
  264. {$ENDC}
  265.  
  266.